Flood myths have been around as long as humans have been around, there are cave paintings depicting waters drowning large amounts of animals and people, all the way back to pre-humans and you can find similar stories as well amongst Native Americans, Aboriginals in Australia and other groups across the world. Given the split between some of those groups happened well before the Bible started to be written (~500-1500BCE) it is likely flood myths had passed through folklore for millennia before ever being written down.
Floods were a part of life until the Romans and later monks started building infrastructure to protect humans, and we are still seeing it today. Imagine living in the area of what is now New Orleans and after a hurricane, your entire 'world' is underwater, as far as you can see and as far as anyone in your tribe ever traveled is submerged. How many people in your tribe would survive? Well, at least enough to reproduce and tell the story ~5-7 is sufficient.